<?php
/**
 * Created on 23/ago/2008
 *
 * Penner's easing equations for php
 * jaco_at_pixeldump
 */
 
class EasingBack {
	
	function easeIn ($t, $b, $c, $d, $s = 1.70158) {
		return $c * ($t /= $d) * $t * (($s + 1) * $t - $s) + $b;
	}
	
	function easeOut ($t, $b, $c, $d, $s = 1.70158) {
		return $c * (($t = $t / $d - 1) * $t * (($s + 1) * $t + $s) + 1) + $b;
	}
	
	function easeInOut ($t, $b, $c, $d, $s = 1.70158) {
		if (($t /= $d / 2) < 1)
			return $c / 2 * ($t * $t * ((($s *= (1.525)) + 1) * $t - $s)) + $b;
		
		return $c / 2 * (($t -= 2) * $t * ((($s *= (1.525)) + 1) * $t + $s) + 2) + $b;
	}
}

class EasingBounce {

	 function easeOut ($t, $b, $c, $d) {
		if (($t /= $d) < (1 / 2.75)) {
			return $c * (7.5625 * $t * $t) + $b;
		} else if ($t < (2 / 2.75)) {
			return $c * (7.5625 * ($t -= (1.5 / 2.75)) * $t + .75) + $b;
		} else if ($t < (2.5 / 2.75)) {
			return $c * (7.5625 * ($t -= (2.25 / 2.75)) * $t + .9375) + $b;
		} else {
			return $c * (7.5625 * ($t -= (2.625 / 2.75)) * $t + .984375) + $b;
		}
	}
	
	function easeIn ($t, $b, $c, $d) {
		return $c - $this->easeOut($d - $t, 0, $c, $d) + $b;
	}
	
	function easeInOut ($t, $b, $c, $d) {
		if ($t < $d / 2) return $this->easeIn ($t * 2, 0, $c, $d) * .5 + $b;
		else return $this->easeOut ($t * 2 - $d, 0, $c, $d) * .5 + $c * .5 + $b;
	}
} 

class EasingCirc {

	function easeIn ($t, $b, $c, $d) {
		return -$c * (sqrt(1 - ($t /= $d) * $t) - 1) + $b;
	}

	function easeOut ($t, $b, $c, $d) {
		return $c * sqrt(1 - ($t = $t / $d-1) * $t) + $b;
	}

	function easeInOut ($t, $b, $c, $d) {
		if (($t /= $d / 2) < 1) return -$c / 2 * (sqrt(1 - $t * $t) - 1) + $b;
		return $c / 2 * (sqrt(1 - ($t -= 2) * $t) + 1) + $b;
	}
}

class EasingCubic {
	
	function easeIn ($t, $b, $c, $d) {
		return $c * ($t /= $d) * $t * $t + $b;
	}
	
	function easeOut ($t, $b, $c, $d) {
		return $c * (($t = $t / $d - 1) * $t * $t + 1) + $b;
	}
	
	function easeInOut ($t, $b, $c, $d) {
		if (($t /= $d / 2) < 1) return $c / 2 * $t * $t * $t + $b;
		return $c / 2 * (($t -= 2) * $t * $t + 2) + $b;
	}
}

class EasingElastic {

	function easeIn ($t, $b, $c, $d, $a, $p) {
		if (!$t) return $b;  if (($t /= $d) == 1) return $b + $c;  if (!$p) $p = $d * .3;

		if (!$a || $a < abs($c)) {
			$a = $c; 
			$s = $p / 4;
		}
		else $s = $p / (2 * pi()) * asin($c / $a);
		
		return -($a * pow(2, 10 * ($t -= 1)) * sin(($t * $d - $s) * (2 * pi()) / $p)) + $b;
	}
	
	function easeOut ($t, $b, $c, $d, $a, $p) {

		if (!$t) return $b;

		if (($t /= $d) == 1) return $b + $c;

		if (!$p) $p = $d * .3;

		if (!$a || $a < abs($c)) {
			$a = $c;
			$s = $p / 4;
		}
		else $s = $p / (2 * pi()) * asin($c / $a);

		return ($a * pow(2, -10 * $t) * sin(($t * $d - $s) * (2 * pi()) / $p ) + $c + $b);
	}
	
	function easeInOut ($t, $b, $c, $d, $a, $p) {

		if (!$t) return $b;
		
		if (($t /= $d / 2) == 2) return $b + $c;
		if (!$p) $p = $d * (.3 * 1.5);
		
		if (!$a || $a < abs($c)) {
			$a = c;
			$s = $p / 4;
		}
		else $s = $p / (2 * pi()) * asin($c / $a);
		
		if ($t < 1) return -.5 * ($a * pow(2, 10 * ($t -= 1)) * sin(($t * $d - $s) * (2 * pi()) / $p)) + $b;
		
		return $a * pow(2, -10 * ($t -= 1)) * sin(($t * $d - $s) * (2 * pi()) / $p) * .5 + $c + $b;
	}
}


class EasingExpo {
	
	function easeIn ($t, $b, $c, $d) {
		return (!$t) ? $b : $c * pow(2, 10 * ($t / $d - 1)) + $b;
	}
	
	function easeOut ($t, $b, $c, $d) {
		return ($t == $d) ? $b + $c : $c * (-pow(2, -10 * $t / $d) + 1) + $b;
	}
	
	function easeInOut ($t, $b, $c, $d) {
		if (!$t) return $b;
		if ($t == $d) return $b + $c;
		if (($t /= $d / 2) < 1) return $c / 2 * pow(2, 10 * ($t - 1)) + $b;
		return $c / 2 * (-pow(2, -10 * --$t) + 2) + $b;
	}
}


class EasingLinear {
	
	function easeNone ($t, $b, $c, $d) { return $c * $t / $d + $b; }
	
	function easeIn ($t, $b, $c, $d) { return $c * $t / $d + $b; }
	
	function easeOut ($t, $b, $c, $d) { return $c * $t / $d + $b; }
	
	function easeInOut ($t, $b, $c, $d) { return $c * $t / $d + $b; }
}

class EasingQuad {
	
	function easeIn ($t, $b, $c, $d) {
		return $c * ($t /= $d) * $t + $b;
	}
	
	function easeOut ($t, $b, $c, $d) {
		return -$c * ($t /= $d) * ($t - 2) + $b;
	}
	
	function easeInOut ($t, $b, $c, $d) {
		if (($t /= $d / 2) < 1) return $c / 2 * $t * $t + $b;
		return -$c / 2 * ((--$t) * ($t - 2) - 1) + $b;
	}
}


class EasingQuart {
	
	function easeIn ($t, $b, $c, $d) {
		return $c * ($t /= $d) * $t * $t * $t + $b;
	}
	
	function easeOut ($t, $b, $c, $d) {
		return -$c * (($t = $t / $d-1) * $t * $t * $t - 1) + $b;
	}
	
	function easeInOut ($t, $b, $c, $d) {
		if (($t /= $d / 2) < 1) return $c / 2 * $t * $t * $t * $t + $b;
		return -$c / 2 * (($t -= 2) * $t * $t * $t - 2) + $b;
	}
}


class EasingQuint {
	
	function easeIn ($t, $b, $c, $d) {
		return $c * ($t /= $d) * $t * $t * $t * $t + $b;
	}
	
	function easeOut ($t, $b, $c, $d) {
		return $c * (($t = $t / $d - 1) * $t * $t* $t * $t * $t + 1) + $b;
	}
	
	function easeInOut ($t, $b, $c, $d) {
		if (($t /= $d / 2) < 1) return $c / 2 * $t * $t * $t * $t * $t + $b;
		return $c / 2 * (($t -= 2) * $t * $t * $t * $t + 2) + $b;
	}
}


class EasingSine {
	
	function easeIn ($t, $b, $c, $d) {
		return -$c * cos($t / $d * (pi() / 2)) + $c + $b;
	}
	
	function easeOut ($t, $b, $c, $d) {
		return $c * sin($t / $d * (pi() / 2)) + $b;
	}
	
	function easeInOut ($t, $b, $c, $d) {
		return -$c / 2 * (cos(pi() * $t / $d) - 1) + $b;
	}
}

// ------------------------- end of penner_easing php classes
?>
